package com.woniu.user.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.woniu.entity.PageResult;
import com.woniu.user.pojo.Feedback;
import com.woniu.user.mapper.FeedbackMapper;
import com.woniu.user.pojo.User;
import com.woniu.user.service.IFeedbackService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 用户反馈表 服务实现类
 * </p>
 *
 * @author LiFangyu
 * @since 2023-02-15
 */
@Service
public class FeedbackServiceImpl extends ServiceImpl<FeedbackMapper, Feedback> implements IFeedbackService {

    @Autowired(required = false)
    private FeedbackMapper feedbackMapper;

    @Override
    public PageResult<Feedback> querySearch(Integer currentPage, Integer pageSize, String userName) {

        // 2. 构建分页对象
        IPage<Feedback> page = new Page<>(currentPage, pageSize);
        // 3. 调用mapper查询数据
        IPage<Feedback> selectPage = feedbackMapper.selectPageFeedback(page,userName);
        // 4. 封装pageResult对象
        PageResult<Feedback> pageResult = new PageResult<>(selectPage.getTotal(), selectPage.getRecords());
        // 5. 返回数据
        return pageResult;
    }

    @Override
    public User queryUser(Integer id) {
        User user = feedbackMapper.queryUser(id);
        return user;
    }

    @Override
    public boolean queryStatus(Long id) {

        boolean b = feedbackMapper.queryStatus(id);
        return false;
    }
}
